package com.rules.admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rules.admin.dao.GroupUserModelDao;
import com.rules.admin.entity.GroupUserModel;
import com.rules.admin.service.GroupUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GroupUserServiceImpl extends ServiceImpl<GroupUserModelDao, GroupUserModel> implements GroupUserService {


   public IPage<GroupUserModel> queryPage(Long groupId, String username, IPage<GroupUserModel> page) {
      LambdaQueryWrapper<GroupUserModel> queryWrapper = new LambdaQueryWrapper<>();
      if (groupId != null) {
         queryWrapper.eq(GroupUserModel::getGroupId,groupId);
      }
      if (StringUtils.isNotBlank(username)) {
         queryWrapper.eq(GroupUserModel::getUsername,username);
      }
      return this.page(page, queryWrapper);
   }

   public GroupUserModel getAccount(Long userId) {
      return this.baseMapper.getUserRecords(userId);
   }
}
